package br.quest;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import android.content.ContentValues;
import android.database.Cursor;

public class AbstractModel {

    protected static String TABLE_NAME;

    /**
     * Prevents this class fom being instanciated. This class should be used like an abstract class, and all methods to
     * be used must be overriden.
     */
    protected AbstractModel() {
    }

    /**
     * Creates and returns a new ContentValues object containing all the columns and values of this object, to be used
     * with a DatabaseAdapter.
     */
    public ContentValues getContentValues() {
        throw new UnsupportedOperationException("Method not yet implemented");
    }

    /**
     * Creates a new instance of this class using information stored on a database Cursor.
     * 
     * @param c The database cursor already set on the right position to get the values.
     */
    public static AbstractModel readFromCursor(Cursor c) {
        throw new UnsupportedOperationException("Method not yet implemented");
    }

    /**
     * Creates a new instance of this class using information stored on a XML element.
     * 
     * @param e The element that contains the information to create the new object.
     */
    public static AbstractModel readFromXML(Element e) {
        throw new UnsupportedOperationException("Method not yet implemented");
    }

    /**
     * Retrieve the value of a tag.
     * 
     * @param tag The name of the tag.
     * @param element The element containing the tag .
     */
    protected static String getTagValue(String tag, Element element) {
        Node textNode = element.getElementsByTagName(tag).item(0).getFirstChild();
        if (textNode != null && textNode.getNodeType() == Node.TEXT_NODE) {
            return textNode.getNodeValue();
        }
        return null;
    }

    /**
     * Return the name of the table associated to this class.
     */
    public String getTableName() {
        return TABLE_NAME;
    }

    /**
     * Returns an array containing the names of all columns of the table associated to this class.
     */
    public String[] getColumns() {
        throw new UnsupportedOperationException("Method not yet implemented");
    }

    /**
     * Returns the SQL command responsible for creating the table associated to this class.
     */
    public String getSqlCreate() {
        throw new UnsupportedOperationException("Method not yet implemented");
    }
}